fix: stop CSP allow-lists triggering challenge detection (#264) - #266
Open
ankitranjan7 wants to merge 1 commit into
Open
fix: stop CSP allow-lists triggering challenge detection (#264)#266ankitranjan7 wants to merge 1 commit into
ankitranjan7 wants to merge 1 commit into
Conversation
isChallengeResponse matched challenge markers against every response header, so any site whose CSP names cdnjs.cloudflare.com or google.com/recaptcha (HN, among many) was classified as a challenge: two wasted impit fetches and a misleading FETCH_BLOCKED for a page that was never blocked. Header evidence is now limited to headers that describe this response (server, cf-mitigated, cf-chl-*, x-datadome*, set-cookie), and a 200 needs body evidence — headers alone never prove a challenge on a served page. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
🟢 No documentation gap found — medium confidenceThe automated review found no documentation gap in the supplied changes. This review is advisory and does not block merging. |
This was referenced Aug 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #264.
The problem
webcmd web fetchwrongly decides a normal page is a bot-challenge page, and gives up on it.The check that spots challenge pages searched every response header for words like
cloudflare,recaptchaandcaptcha. Plenty of healthy sites list those domains in theircontent-security-policyheader — that header is just an allow-list of third parties, not a statement about this response.Hacker News is one of them. It returns a healthy
200with the full page, gets labelled a challenge, retries through the whole impit ladder for nothing, and then fails:The page was never blocked. Any site whose CSP names a CDN or reCAPTCHA — a large share of the web — paid two wasted fetches and then a misleading
FETCH_BLOCKED.What I changed
src/fetch/classify.ts:server,cf-mitigated,cf-chl-*,x-datadome*,set-cookie.content-security-policy,report-toandlinkare ignored — they are third-party allow-lists and prove nothing.200now needs evidence in the body before it counts as a challenge.server: cloudflareon a page that was actually served is not a challenge; a real interstitial still says "Just a moment" in the body, and that still matches.Proof
npx vitest run src/fetch/→ 22 passed.npm run typecheckclean.200, and that a real403+server: cloudflareis still classified as a challenge (no under-detection).🤖 Generated with Claude Code